package com.fluxtah.jordl.examples.twitter;

import com.fluxtah.jordl.lib.Transformer;
import com.fluxtah.jordl.lib.TransformException;
import java.util.List;
import org.json.JSONArray;
import org.json.JSONException;

public class TwitterUserListInputTransformer extends Transformer<JSONArray, List<TwitterUser>> {
	public void transform(JSONArray source, List<TwitterUser> target) throws TransformException {
		try {
			TwitterUserInputTransformer itemTransformer = provider.get(TwitterUserInputTransformer.class);
			for(int i=0; i < source.length(); i++) {
				TwitterUser targetItem = new TwitterUser();
				itemTransformer.transform(source.getJSONObject(i), targetItem);
				target.add(targetItem);
			}
		} catch (JSONException x) {
			throw new TransformException(x);
		}
	}
}
